const mysql = require('mysql')

const pool = mysql.createPool({
    connectionLimit:50,
    host:'110.40.250.12',
    user:'root',
    password:'',
    database:'chinesepainting',
    multipleStatements:true
})

let query = function (sql,values){
    return new Promise((resolve,reject)=>{
        pool.getConnection(function (err,connection){
            if(err){
                reject(err)
            }else{
                connection.query(sql,values,(err,rows)=>{
                    if(err){
                        reject(err)
                    }else{
                        resolve(rows)
                    }
                    connection.release()
                })
            }
        })
    })
}

module.exports = query;